package edu.lnu.project.timeeditapp.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class TimeEditDbHelper extends SQLiteOpenHelper {
	
	public static final String TIMETABLE_TABLE_NAME = "timeTable";
	public static final String COLUMN_ID = "_id";
	public static final String COLUMN_WEEKDAY = "weekday";
	public static final String COLUMN_BEGINDATE = "beginDate";
	public static final String COLUMN_BEGINTIME = "beginTime";
	public static final String COLUMN_ENDDATE = "endDate";
	public static final String COLUMN_ENDTIME = "endTime";
	public static final String COLUMN_COURSE = "course";
	public static final String COLUMN_PROGRAMME = "programme";
	public static final String COLUMN_COURSEEVENT = "courseEvent";
	public static final String COLUMN_PROGRAMMEEVENT = "programmeEvent";
	public static final String COLUMN_ROOM = "room";
	public static final String COLUMN_TEACHER = "teacher";
	public static final String COLUMN_STUDENTGROUP = "studentGroup";
	public static final String COLUMN_ACTIVITY = "activity";
	public static final String COLUMN_EXAMCODE = "examCode";
	public static final String COLUMN_COMMENTS = "comments";
	public static final String COLUMN_CITY = "city";
	public static final String COLUMN_REMINDER = "reminder";
	public static final String COLUMN_WEEK = "week";
	
	
	


	private static final String DATABASE_NAME = "timeTableDB.db";
	private static final int DATABASE_VERSION = 1;

	private static final String DATABASE_CREATE = "create table " + TIMETABLE_TABLE_NAME 
			+ " (" + COLUMN_ID + " integer primary key autoincrement, "
			+ COLUMN_WEEKDAY + " text, "
			+ COLUMN_BEGINDATE + " text, "
			+ COLUMN_BEGINTIME + " text, "
			+ COLUMN_ENDDATE + " text, "
			+ COLUMN_ENDTIME + " text, "
			+ COLUMN_COURSE + " text, "
			+ COLUMN_PROGRAMME + " text, "
			+ COLUMN_COURSEEVENT + " text, "
			+ COLUMN_PROGRAMMEEVENT + " text, "
			+ COLUMN_ROOM + " text, "
			+ COLUMN_TEACHER + " text, "
			+ COLUMN_STUDENTGROUP + " text, "
			+ COLUMN_ACTIVITY + " text, "
			+ COLUMN_EXAMCODE + " text, "
			+ COLUMN_COMMENTS + " text, "
			+ COLUMN_CITY + " text, "
			+ COLUMN_REMINDER + " booelan, "
			+ COLUMN_WEEK + " int );"
			;

	public TimeEditDbHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(DATABASE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w(TimeEditDbHelper.class.getName(), "Upgrading database from version " 
				+ oldVersion + " to " + newVersion 
				+ ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS " + TIMETABLE_TABLE_NAME);
		onCreate(db);
	}


}
